﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using emp.Model;
using emp.BLL;
using emp.ProcessFlow;

public partial class crm_individuals_SearchpotentialCustomers_ : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            //绑定大区
            BListCondition list = new BListCondition();
            IList data = list.getRegion();
            this.region.Items.Add(new ListItem("请选择", "0"));
            for (int i = 0; i < data.Count; i++)
            {
                this.region.Items.Add(new ListItem(((ProvinceInfo)data[i]).PVE_REGION, ((ProvinceInfo)data[i]).PVE_REGION));
            }
            //绑定车品牌
            IList BRAND = new emp.BLL.Individuals().getBrandModelList();
            this.IOF_CAR_BRAND.DataSource = BRAND;
            this.IOF_CAR_BRAND.DataTextField = "cbm_brand";
            this.IOF_CAR_BRAND.DataValueField = "cbm_brand";
            this.IOF_CAR_BRAND.DataBind();
            IOF_CAR_BRAND.Items.Insert(0, "请选择");
            //绑定活动名称
            IList camList = new emp.BLL.Campaign().getCampaignList();
            this.CAM_NAME.DataSource = camList;
            this.CAM_NAME.DataTextField = "Cam_name";
            this.CAM_NAME.DataValueField = "Cam_name";
            this.CAM_NAME.DataBind();
            CAM_NAME.Items.Insert(0, "请选择");
            //绑定购车预算
            DataTable ysdt = new emp.BLL.Individuals().getLCB_BUDGET();
            this.IOF_PLAN_PUR_BUDGET.DataSource = ysdt;
            this.IOF_PLAN_PUR_BUDGET.DataTextField = "LCB_BUDGET";
            this.IOF_PLAN_PUR_BUDGET.DataValueField = "LCB_BUDGET";
            this.IOF_PLAN_PUR_BUDGET.DataBind();
            IOF_PLAN_PUR_BUDGET.Items.Insert(0, "请选择");
            //绑定所有奥迪车型
            DataTable modelDT = new emp.BLL.Individuals().getLCB_CAR_MODEL();
            this.IOF_FIELDS_103.DataSource = modelDT;
            this.IOF_FIELDS_103.DataTextField = "LCB_CAR_MODEL";
            this.IOF_FIELDS_103.DataValueField = "LCB_CAR_MODEL";
            this.IOF_FIELDS_103.DataBind();
            IOF_FIELDS_103.Items.Insert(0, "请选择");

        }
    }
    protected void region_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.IND_PROVINCE.Items.Clear();
        this.ind_city.Items.Clear();
        if (region.SelectedValue != "0")
        {
            BListCondition list = new BListCondition();
            IList data = list.getProvince(region.SelectedValue);
            this.IND_PROVINCE.Items.Add(new ListItem("请选择", "0"));
            for (int i = 0; i < data.Count; i++)
            {
                this.IND_PROVINCE.Items.Add(new ListItem(((ProvinceInfo)data[i]).PVE_NAME, ((ProvinceInfo)data[i]).PVE_NAME));
                // this.IND_PROVINCE.Items.Add(new ListItem(((ProvinceInfo)data[i]).PVE_NAME, ((ProvinceInfo)data[i]).PVE_ID.ToString()));
            }
        }
    }
    protected void IND_PROVINCE_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.ind_city.Items.Clear();
        if (IND_PROVINCE.SelectedValue != "0")
        {
            BListCondition list = new BListCondition();
            IList data = list.getCity(IND_PROVINCE.SelectedValue);
            //IList data = list.getCity(Convert.ToInt32(IND_PROVINCE.SelectedValue));
            this.ind_city.Items.Add(new ListItem("请选择", ""));
            for (int i = 0; i < data.Count; i++)
            {
                this.ind_city.Items.Add(new ListItem(((CityInfo)data[i]).CITY_NAME, ((CityInfo)data[i]).CITY_NAME));


            }
        }
    }
    protected void querys_Click(object sender, EventArgs e)
    {
        emp.Model.CustomerInfo cInfo = new CustomerInfo();
        if (this.IND_URN.Text != "")
        {
            cInfo.IND_URN =Convert.ToInt32( this.IND_URN.Text);
        }
        if (this.IND_NAME.Text != "")
        {
            cInfo.IND_NAME = this.IND_NAME.Text;
        }
        if (IND_GENDER1.Checked)
        {
            cInfo.IND_GENDER = "M";
        }
        if (IND_GENDER2.Checked)
        {
            cInfo.IND_GENDER = "F";
        }
        if (this.region.SelectedValue != "" && this.region.SelectedIndex != 0)
        {
            cInfo.IND_DISTRICT_1 = this.region.SelectedValue;
        }
        if (this.IND_PROVINCE.SelectedValue != "" && this.IND_PROVINCE.SelectedIndex!=0)
        {
            cInfo.IND_PROVINCE = this.IND_PROVINCE.SelectedValue;
        }
        if (this.ind_city.SelectedValue != "" && this.ind_city.SelectedIndex!=0)
        {
            cInfo.IND_CITY = this.ind_city.SelectedValue;
        }
        if (this.IND_CITY_OTHER.Text != "")
        {
            cInfo.IND_CITY_OTHER = this.IND_CITY_OTHER.Text;
        }


        if (this.IND_ADDRESS_1.Text != "")
        {
            cInfo.IND_ADDRESS_1 = this.IND_ADDRESS_1.Text;
        }
        if (this.IND_CELLPHONE_1.Text != "")
        {
            cInfo.IND_CELLPHONE_1 = this.IND_CELLPHONE_1.Text;
        }
        if (this.IND_TEL_AREA_1.Text != "")
        {
            cInfo.IND_TEL_AREA_1 = this.IND_TEL_AREA_1.Text;
        }
        if (this.IND_TEL_1.Text != "")
        {
            cInfo.IND_TEL_1 = this.IND_TEL_1.Text;
        }
        if (this.IND_EMAIL_1.Text != "")
        {
            cInfo.IND_EMAIL_1 = this.IND_EMAIL_1.Text;
        }

        if (IOF_OWER_TYPE.Checked)
        {
            cInfo.IOF_OWER_TYPE = "Y";
        }

        if (this.IOF_CAR_BRAND.SelectedValue != "" && this.IOF_CAR_BRAND.SelectedIndex != 0)
        {
            cInfo.IOF_CAR_BRAND = this.IOF_CAR_BRAND.SelectedValue;
        }
        if (this.IOF_CAR_MODEL.SelectedValue != "" && this.IOF_CAR_MODEL.SelectedIndex != 0)
        {
            cInfo.IOF_CAR_MODEL = this.IOF_CAR_MODEL.SelectedValue;
        }
        if (this.IOF_PLAN_PUR_DATE.SelectedValue != "" && this.IOF_PLAN_PUR_DATE.SelectedIndex != 0)
        {
            cInfo.IOF_PLAN_PUR_DATE = this.IOF_PLAN_PUR_DATE.SelectedValue;
        }
        if (this.IOF_PLAN_PUR.SelectedValue != "" && this.IOF_PLAN_PUR.SelectedIndex != 0)
        {
            cInfo.IOF_PLAN_PUR = this.IOF_PLAN_PUR.SelectedValue;
        }
        if (this.IOF_PLAN_PUR_BUDGET.SelectedValue != "" && this.IOF_PLAN_PUR_BUDGET.SelectedIndex != 0)
        {
            cInfo.IOF_PLAN_PUR_BUDGET = this.IOF_PLAN_PUR_BUDGET.SelectedValue;
        }
        if (this.INO_IS_LEADS.SelectedValue != "" && this.INO_IS_LEADS.SelectedIndex != 0)
        {
            cInfo.INO_IS_LEADS = this.INO_IS_LEADS.SelectedValue;
        }
        if (this.IND_DEALER_NFC.SelectedValue != "" && this.IND_DEALER_NFC.SelectedIndex != 0)
        {
            cInfo.IND_DEALER_NFC = this.IND_DEALER_NFC.SelectedValue;
        }
        if (this.IOF_FIELDS_103.SelectedValue != "" && this.IOF_FIELDS_103.SelectedIndex != 0)
        {
            cInfo.IOF_FIELDS_103 = this.IOF_FIELDS_103.SelectedValue;
        }
        if (this.CAM_NAME.SelectedValue != "" && this.CAM_NAME.SelectedIndex != 0)
        {
            cInfo.CAM_NAME = this.CAM_NAME.SelectedValue;
        }

        if (IND_ADDRESS_1_T.Checked)
        {
            cInfo.IND_ADDRESS_1_T = "Y";
        }
        if (IND_CELLPHONE_1_T.Checked)
        {
            cInfo.IND_CELLPHONE_1_T = "Y";
        }
        if (IND_EMAIL_1_T.Checked)
        {
            cInfo.IND_EMAIL_1_T = "Y";
        }

        emp.Model.Attachment att = new Attachment();
        if (this.IND_IS_ATTACHMENT.Checked || this.CheckBox1.Checked || this.CheckBox2.Checked || this.CheckBox3.Checked)
        {

            if (this.IND_IS_ATTACHMENT.Checked)
            {
                att.INA_IS_CARD = "是";
            }
            if (this.CheckBox1.Checked)
            {
                att.INA_IS_DLICENSE = "是";
            }
            if (this.CheckBox2.Checked)
            {
                att.INA_IS_PERMIT = "是";
            }
            if (this.CheckBox3.Checked)
            {
                att.IND_IS_IDENTITY = "是";
            }

        }
        IndividualsController ic = new IndividualsController();
        ic.getControllerList(cInfo, att);


            

    }
    protected void IOF_CAR_BRAND_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.IOF_CAR_BRAND.SelectedIndex == 0)
        {
            this.IOF_CAR_MODEL.Items.Clear();
        }
        else 
        {
            Brand brand = new Brand();
            IList BRAND = brand.getBrandModelList(this.IOF_CAR_BRAND.SelectedValue.ToString(), "");
            this.IOF_CAR_MODEL.DataSource = BRAND;
            this.IOF_CAR_MODEL.DataTextField = "cbm_model";
            this.IOF_CAR_MODEL.DataValueField = "cbm_model";
            this.IOF_CAR_MODEL.DataBind();
            IOF_CAR_MODEL.Items.Insert(0, "请选择");
        }
    }
}
